<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#import "/layout/select.ftl" as my/>
<#assign css>
    <link rel="stylesheet" href="/assets/vendor/bootstrap-datepicker/css/bootstrap-datepicker3.css">
    <style>

    </style>
</#assign>
<#assign js>
    <script src="/assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script type="text/javascript" src="/assets/vendor/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"
            charset="UTF-8"></script>
    <script>
        //tableId,queryId,conditionContainer
        //var userTable;
        $(function () {
            //Date picker
            $('#datepicker').datepicker({
                autoclose: true,
                format: "yyyy-mm-dd",
                todayHighlight: true,
                language: "zh-CN"
            });
            $('#datepicker-end').datepicker({
                autoclose: true,
                format: "yyyy-mm-dd",
                todayHighlight: true,
                language: "zh-CN"
            });
            $('#datepicker').unbind("change");
            $('#datepicker').change(function () {
                $('#datepicker-end').datepicker('setStartDate', $("#datepicker").val());
            });
            $('#datepicker-end').unbind("change");
            $('#datepicker-end').change(function () {
                $('#datepicker').datepicker('setEndDate', $("#datepicker-end").val());
            });

            $('input[name="status"]').click(function () {
                $('#form').submit();
            })

            <#if errorMsg??>
            layer.alert('${errorMsg}');
            </#if>
        });
    </script>
</#assign>
<@layout title="交易汇总" active="agent">
    <!-- Content Header (Page header) -->

    <!-- Main content -->
    <section class="content">
        <!-- Default box -->
        <div class="box box-primary">
            <div class="box-header">
                <form class="form-horizontal form-edit" method="get" action="/agent/agentOrder" id="form">
                    <input type="hidden" name="agentId" value="${orderReq.agentId!}">
                    <div class="form-group">
                        <div class="col-sm-12">
                            <div class="input-group">
                                <label>业务类型：</label>
                                <input type="radio" name="tranType" id="tranType_all" value="" <#if orderReq.tranType == ''>checked="checked"</#if>>
                                <label for="tranType_all" style="margin-left: 5px;margin-right: 5px">全部</label>
                                <input type="radio" name="tranType" id="tranType_paotui" value="1" <#if orderReq.tranType == '1'>checked="checked"</#if>>
                                <label for="tranType_paotui" style="margin-left: 5px;margin-right: 5px">跑腿</label>
                                <input type="radio" name="tranType" id="tranType_other" value="2" <#if orderReq.tranType == '2'>checked="checked"</#if>>
                                <label for="tranType_other" style="margin-left: 5px;margin-right: 5px">其他</label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-2">
                            <div class="input-group date">
                                <div class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </div>
                                <input type="text" placeholder="开始日期" name="startTime" class="form-control pull-right"
                                       id="datepicker" value="${orderReq.startTime!}">
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <div class="input-group date">
                                <div class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </div>
                                <input type="text" placeholder="结束日期" name="endTime" class="form-control pull-right"
                                       id="datepicker-end" value="${orderReq.endTime!}">
                            </div>
                        </div>

                        <div class="btn-group">
                            <button type="submit" class="btn btn-primary" data-btn-type="search">查询</button>
                            <button type="button" class="btn btn-default" data-btn-type="reset"
                                    onclick="javascript:$('#form')[0].reset();">重置
                            </button>
                            <a class="btn btn-success" href="/agent/agentOrderExport?agentId=${orderReq.agentId!}&startTime=${orderReq.startTime!}&endTime=${orderReq.endTime!}&tranType=${orderReq.tranType!}">导出</a>
                        </div>
                    </div>
                </form>
            </div>
            <div class="box-body">
                <table class="table table-striped bring-up nth-2-center">
                    <tr>
                        <th>账单总额</th>
                        <th>平台收益</th>
                        <th>分站收益</th>
                        <th>师傅收益</th>
                        <th>有效单数</th>
                        <th>取消单数</th>
                    </tr>
                    <tr>
                        <td>${collect.total_order_amount?string('0.00')!}</td>
                        <td>${collect.platform?string('0.00')!}</td>
                        <td>${collect.agent?string('0.00')!}</td>
                        <td>${collect.master?string('0.00')!}</td>
                        <td>${collect.valid_count!}</td>
                        <td>${collect.invalid_count!}</td>
                    </tr>
                </table>
                <table class="table table-striped">
                    <tr>
                        <th>日期</th>
                        <th>业务类型</th>
                        <th>平台收益</th>
                        <th>分站收益</th>
                        <th>师傅收益</th>
                        <th>优惠款</th>
                        <th>有效单数</th>
                        <th>取消单数</th>
                    </tr>
                    <#list agentOrderList as item>
                        <tr>
                            <td>${(item.tranTime?string('yyyy-MM-dd'))!}</td>
                            <td>${item.tranType!}</td>
                            <td>${item.platformIncome?string('0.00')!}</td>
                            <td>${item.agentIncome?string('0.00')!}</td>
                            <td>${item.masterIncome?string('0.00')!}</td>
                            <td>${item.offer!}</td>
                            <td>${item.validCount!}</td>
                            <td>${item.invalidCount!}</td>
                        </tr>
                    </#list>
                </table>
            </div>
        </div>
        <!-- /.box -->

    </section>
    <!-- /.content -->
</@layout>
